package com.xjoyt.pay.master.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import com.xjoyt.pay.abstracts.AbstractDao;
import com.xjoyt.pay.master.dao.MerchantRateRepositoryCustom;
import com.xjoyt.pay.master.po.MerchantRate;
import com.xjoyt.pay.master.repository.MerchantRateRepository;
import com.xjoyt.pay.vo.PayType;

public class MerchantRateRepositoryImpl extends AbstractDao implements MerchantRateRepositoryCustom {

	@Autowired
	private MerchantRateRepository repository;

	@Override
	public MerchantRate findOneByMerchantIdAndType(String merchantId, PayType type) {
		Page<MerchantRate> page = repository.findAllByMerchantIdAndType(merchantId, type, getFirstPageable());
		return page.hasContent() ? page.iterator().next() : null;
	}

}
